// #include "Unit.hpp"
// #include "Level.hpp"
// #include "LogMessage.hpp"
// #include "Format.hpp"
// #include "LogLand.hpp"
#include "Log.h"
#include <unistd.h>

// void test()
// {

//     MyLogger::BuildGlobalLogger

// }
int main()
{
    //

    // LogMessage::LogMeg lms(LogLevel::Level::DEBUG, 7, "Main.cpp", "功能测试", "log1");
    // Format::ForMatter Fmater;
    // MyLogBuffer::LogBuffer buffer;
    // for(int i=0;i<1000;i++)
    // {
    //     buffer.push( Fmater.format(lms));
    // }
    // size_t nums=buffer.GetRMesNum();
    // std::cout<<nums<<std::endl;
    // Fmater.format(std::cout,lms);std::shared_ptr<LogLand> LToF = LandFactory<LogToFile, std::string>::CreateLogLand("./log/log1.txt");
    // buffer.print_r();
    // for(int i=0;i<nums;i++)
    // {
    //     LToF->WriteLog(buffer.GetCurRPos().c_str(),buffer.GetCurRPos().length());
    //     buffer.ReadPosOffSet();
    // }
    // buffer.print_r();
    // buffer.print_w();
    //std::shared_ptr<LogLand> LToF = LandFactory<LogToFile, std::string>::CreateLogLand("./Usynclog/log1.txt");
    // // 传入对应的构造函数的参数类型给参数包string,int-->"./Log/log-", 300
    // std::shared_ptr<LogLand> LtoR = LandFactory<LogToRollFile, std::string, int>::CreateLogLand("./UsyncLog/log-", 300);
    // std::shared_ptr<LogLand> LtoStd = LandFactory<LogToStdOut>::CreateLogLand();
    // std::vector<std::shared_ptr<LogLand>> LLd = {
    //     LToF, LtoR, LtoStd};
    // std::shared_ptr<Format::ForMatter> Fmater = std::make_shared<Format::ForMatter>();
    // std::shared_ptr<MyLogger::Logger> LogPtr = std::make_shared<SynLogger>("Log1", LogLevel::Level::INFO, Fmater, LLd);
    std::unique_ptr<MyLogger::LoggerBuilder> Buile = std::make_unique<MyLogger::BuildLocalLogger>("Log1");

    Buile->BuildLoggerType(MyLogger::LoggerType::LOGGER_USYNC);
    Buile->BuiltLogLand<LogToFile>("./Usynclog/log1.txt");
    // Buile->BuiltLogLand<LogToStdOut>();
    //Buile->BuiltLogLand<LogToRollFile>("./UsyncLog/log-", 1000);
    std::shared_ptr<MyLogger::Logger> LogPtr = Buile->Build();
    MyLogger::LoggerManager::GerInsrance().AddLogger(LogPtr);
    for (int i = 0; i < 100000; i++)
    {
        //预处理阶段会把Fatal("%s%d", "测试功能1", 777);
        //替换成Fatal(__FILE__, __LINE__, "%s%d", "测试功能1", 777);
        //宏函数加文本替换，编译阶段再做语法检查，
        LogPtr->Fatal("%s%d", "测试功能1", 777);
        //LogPtr->Infor(__FILE__, __LINE__, "%s%d", "测试功能2", 777);
        //FATAL("%s%d", "测试功能1", 777);
    }
    // LogMessage::LogMeg lms(LogLevel::Level::DEBUG, 7, "Main.cpp", "功能测试", "log1");
    //  Format::ForMatter Fmater("%rrrrrr%%%nnnn[%d][%l],%m%n%ngg%g%n");
    //  Format::ForMatter Fmater("sadas%%%%%%%%");
    //  Format::ForMatter Fmater("");
    // Format::ForMatter Fmater;
    //  Fmater.format(std::cout,lms);

    // std::string Ma = Fmater.format(lms);
    // std::shared_ptr<LogLand> LToF=LandFactory<LogToFile,std::string>::CreateLogLand("./log/log1.txt");
    // LogToFile LToF("./log/log1.txt");
    // LToF->WriteLog(Ma.c_str(), Ma.size());
    // LToF->WriteLog(Ma.c_str(), Ma.size());
    // LToF->WriteLog(Ma.c_str(), Ma.size());
    // 传入对应的构造函数的参数类型给参数包string,int-->"./Log/log-", 300
    // std::shared_ptr<LogLand> LtoR=LandFactory<LogToRollFile,std::string,int>::CreateLogLand("./Log/log-", 300);

    // LogToRollFile LtoR("./Log/log-", 300);
    // for (int i = 0; i < 100; i++)
    // LtoR->WriteLog(Ma.c_str(), Ma.size());
    // std::cout<<LogLevel::LevelToStr(LogLevel::Level::DEBUG)<<std::endl;
    //  std::cout<<LogLevel::LevelToStr(LogLevel::Level::INFO)<<std::endl;
    // if(!MyLog::File::PathExist("/home/cxk/Linux/linux-learning/日志系统/日志项目/a/b/c.txt"))
    // {
    //     MyLog::File::MakeDirector("/home/cxk/Linux/linux-learning/日志系统/日志项目/a/b/c.txt");
    // }
}